package myaddressbook;

import java.awt.Container;
import java.awt.GridLayout;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.WindowConstants;

import listerner.CancelListerner;
import listerner.DeleteListerner;
import listerner.ModifyListerner;
import listerner.SearchListerner;

public class Search {
	public static JFrame frame;
	public Search() {
		// TODO Auto-generated constructor stub
	}
	public JDialog dialog=new JDialog(frame,"查询",true);
	public Search(String str,int n){
		dialog.setSize(250,200);
		Container c=dialog.getContentPane();
		dialog.setLayout(new GridLayout(2,1,5,5));
		JLabel Lsearch=new JLabel("请输入要"+str+"人员的名字：");
		final JTextField Tname=new JTextField(10);
		JButton certain=new JButton("确定");
		JButton cancel=new JButton("取消");
		JPanel pane1=new JPanel();
		JPanel pane2=new JPanel();
		c.add(pane1);
		c.add(pane2);
		pane1.add(Lsearch);
		pane1.add(Tname);
		pane2.add(certain);
		pane2.add(cancel);
		dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		if(n==2){
			certain.addActionListener(new SearchListerner(Tname,dialog));
			}
		if(n==3){
			certain.addActionListener(new DeleteListerner(Tname,dialog));
			}
		if(n==4){
			certain.addActionListener(new ModifyListerner(Tname,dialog));
			}
		cancel.addActionListener(new CancelListerner(dialog));
		}
}
